<?php
include_once 'include.php';
$ImageObj = new Image();

$id = $_POST['id'];
$select = mysql_query("SELECT `photourl` FROM `".$ImageObj->get_table_name()."` WHERE `id` = '".$id."'");
$row = mysql_fetch_assoc($select);
$file_name = basename($row['photourl']);

$sql = "DELETE FROM `".$ImageObj->get_table_name()."` WHERE `id` = '".$id."'";
if(mysql_query($sql)){
	unlink("../uploads/".$file_name);
	unlink("../uploads/original_imgs/".$file_name);
	unlink("../uploads/thumbnails/thumbnail_".$file_name);
}
else echo "error";
?>